<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>
    <link rel="stylesheet" type="text/css" href="/Public/Admin/common/bootstrap/css/bootstrap.css" media="all">
    <!--<link href="/Public/Admin/css/new_plan.css" rel="stylesheet" />-->
    <style>
        .menuParent .roleSpan{font-size: 14px;font-weight: bold;margin: 6px 0;position: relative;padding-left:15px}
        .menuChild .roleSpan{position: relative;padding-left:15px}
        .roleSpan{display:inline-block;margin:5px 20px 5px 0;}
        .menuParent .roleSpan input,.menuChild .roleSpan input{position: absolute;left:0;top:-3.5px}
    </style>
</block>
<block name="content"> 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab">
                <blockquote class="layui-elem-quote news_search">
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:U('Index/role')}">返回</a>
                    </div>
                </blockquote>

                <!-- 表单项 -->
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">角色名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="priv_name" {$id ? 'readonly' : ''} class="layui-input" value="{$info.priv_name}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">角色序号</label>
                        <div class="layui-input-block">
                            <input type="text" {$id ? 'readonly' : ''} name="priv_no" class="layui-input" value="{$info.priv_no}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">开放权限</label>
                        <div class="layui-input-block">
                            <foreach name="menus" item="menu">
                                <div style="margin-bottom:15px;border-bottom: 1px solid #e6e6e6">
                                    <div class="menuParent">
                                        <span class="roleSpan"><input type="checkbox" name="menu_id[]" value="{$menu.id}"
                                                                      <foreach name="info.menuIds" item="mid">
                                                <if condition="$menu['id'] eq $mid">checked</if>
                                            </foreach>
                                            >{$menu.name}</span>
                                    </div>
                                    <div class="menuChild">
                                        <foreach name="menu.child" item="child">
                                            <span class="roleSpan"><input type="checkbox" name="menu_id[]" value="{$child.id}" 
                                                                          <foreach name="info.menuIds" item="mid">
                                                    <if condition="$child['id'] eq $mid">checked</if>
                                                </foreach>
                                                >{$child.name}</span>
                                        </foreach>
                                    </div>
                                </div>
                            </foreach>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block button">
                            <input type='hidden' name='id' value='{$info.user_priv|default=0}'>
                            <a class="layui-btn btn-submit ajax-post" data-url="{:U('saveRole')}" data-form="">提交</a>
                            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                        </div>
                    </div>
                </form>
                <!-- 完 -->
            </div>
        </div>
    </section>
</block>
<block name="script">
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
    <script type="text/javascript">
        $(initRole());
    </script>    
</block>

